package com.zsinfo.guoss.supplier.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.example.netcenter.Event.Response;
import com.example.netcenter.RetrofitBuilder;
import com.example.netcenter.Url.ConstantsCode;
import com.example.netcenter.bean.AliCountBean;
import com.example.netcenter.bean.UserBean;
import com.zsinfo.guoss.supplier.R;
import com.zsinfo.guoss.supplier.base.BaseActivity;
import com.zsinfo.guoss.supplier.utils.SharedPreferencesUtil;

import butterknife.BindView;
import butterknife.OnClick;


public class AddStationInfoActivity extends BaseActivity {


    private String type = "";
    @BindView(R.id.other_name)
    TextView other_name;

    private String mType = "0";

    @Override
    protected int getContentLayoutRes() {
        return R.layout.activity_add_station_info;
    }

    @Override
    protected void initView() {


        setBackAndLeftTitle("").setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        type = getIntent().getStringExtra("TypeValue");


        String title = "";
        switch (type) {
            case "1":
                title = "姓名";
                mType = "1";
                break;
            case "2":
                title = "地址(或档口号)";
                mType = "2";
                break;
            case "3":
                mType = "3";
                title = "主营业务";
                break;
        }

        setTitle(title);


        other_name.setText(getIntent().getStringExtra("TypeCount"));

    }


    @OnClick({R.id.btn_addInfo})
    void addInfo() {


        if (other_name.getText().toString().isEmpty()) {
            showToast("请输入信息内容");
            return;
        }

        if (!mType.equals("0")) {


            GetNetCenter().GetNetCenter(this, RetrofitBuilder.CreateApi().UPDATE_PER_INFO(ConstantsCode.update_per_info,
                    SharedPreferencesUtil.getID(),
                    other_name.getText().toString(),
                    mType),
                    new Response() {
                        @Override
                        public void OK(Object data) {

                            AliCountBean aliCountBean = (AliCountBean) data;

                            SharedPreferencesUtil.setfirmName(aliCountBean.getData().getName());

                            finish();


                        }

                        @Override
                        public void Fail(Throwable e) {

                        }

                        @Override
                        public void complete() {

                        }
                    });

        }
    }

    @Override
    protected void initNetData() {

    }

    @Override
    protected void customDestroy() {

    }
}
